<?php

$userid = get_loggedin_userid();
$client_id = get_input('client_id');
$json_contact_emails = get_input('contact_emails');
$brief = get_input('brief');
$users = array();

if($json_contact_emails) {
    $contact_emails = json_decode($json_contact_emails, true);
    $users[] = get_user_by_email($contact_emails);
}

$results = array();
foreach ($users as $user) {
    $results[] = userToArray($user, $client_id, $brief);
}

echo json_encode(export_result(200, $results));
?>